package dao.version4;

import utils.version3.ConnectionUtil;
import utils.version4.ConnetionFactory;
import utils.version4.TransactionManager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UserInfoDao {

   private ConnetionFactory factory;

    public UserInfoDao(ConnetionFactory factory) {
        this.factory = factory;
    }

    public  void deleteById(String userid) {

        String sql = "delete FROM userinfo where userid=?";

        try {
            PreparedStatement preparedStatement = factory.getCurrentConnection().prepareStatement(sql);
            preparedStatement.setString(1,userid);
            preparedStatement.executeUpdate();
            preparedStatement.close();
        } catch (SQLException e) {
            throw new RuntimeException("delete failed in userinfodao");
        }
    }
}
